<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<body>

<div class="layui-card">

    <div class="layui-card-header">
        <span class="layui-icon font-s10 color-desc margin-right-5"></span>专家管理
        <div class="pull-right">
            <button data-table-id="NoticeTable" class="layui-btn layui-btn-primary  layui-btn-sm" data-modal="/system/expert/form" data-height="580px" data-width="600px">
                <i class=" layui-icon layui-icon-addition"></i>添加专家</button>
        </div>
    </div>

    <div class="layui-card-line"></div>

    <div class="layui-card-body">

        <div class="layui-card-table layui-tab">
            <div class="layui-tab-content">

                <table id="ExpertTable" data-url="/system/expert/index"></table>
                <script type="text/javascript" th:inline="none">
                    $(function () {
                        $('#ExpertTable').layTable({
                            even: true,
                            height: 'full',
                            page: false,
                            cols: [[
                                {field: 'name', title: '姓名', minWidth: 180},
                                {field: 'level', title: '级别', minWidth: 180},
                                {field: 'techTitle', title: '职称', minWidth: 180},
                                {field: 'hosName', title: '医院', minWidth: 180},
                                {field: 'status', title: '状态', align: 'center', templet: '#StatusSwitchTpl'},
                                {toolbar: '#expertToolbar', title: '操作', align: 'center', minWidth: 50, fixed: 'right'}
                            ]]
                        });
                    });

                    // 数据状态切换操作
                    layui.form.on('switch(StatusSwitch)', function (obj) {
                        console.log("OBJ", obj)
                        var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
                        $.form.load("/system/manager/state", data, 'post', function (ret) {
                            if (ret.code < 1) $.msg.error(ret.info, 3, function () {
                                $('#UserTable').trigger('reload');
                            }); else {
                                $('#UserTable').trigger('reload')
                            }
                            return false;
                        }, false);
                    });

                </script>

                <!-- 数据状态切换模板 -->
                <script type="text/html" id="StatusSwitchTpl">
                    <input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{-d.status>0?'checked':''}}>
                    <!--                    {{-d.status ? '<b class="color-green">已启用</b>' : '<b class="color-red">已禁用</b>'}}-->
                </script>


                <script type="text/html" id="expertToolbar">

                    <a class="layui-btn layui-btn-sm" data-event-dbclick data-title="编辑" data-height="580px" data-width="600px" data-modal='/system/expert/form?id={{d.id}}'>编 辑</a>

                    <a data-dbclick class="layui-btn layui-btn-sm" data-width="800px" data-height="360px"
                       data-title="账户设置" data-modal="/system/user/index?type=2&cid={{d.id}}"><i
                            class="layui-icon layui-icon-friends"></i>账户设置</a>

                </script>



            </div>
        </div>
    </div>

</div>

</body>
</html>